﻿using System;
using System.ComponentModel;
using System.Windows.Controls;

namespace QuizzMe.Helpers
{
    /// <summary>
    /// Abstract class to extend page functionnalities
    /// </summary>
    public class BasePage : Page, INotifyPropertyChanged
    {
        private String _title;
        private bool _loading;

        /// <summary>
        /// Title of page
        /// </summary>
        public String PageTitle
        {
            get { return _title; } 
            set
            {
                if (_title != value)
                {
                    _title = value;
                    OnPropertyChanged("Title");
                }
            }
        }

        /// <summary>
        /// Loading in progress (show / hide the loading panel)
        /// </summary>
        public bool Loading
        {
            get { return _loading; }
            set
            {
                if (_loading != value)
                {
                    _loading = value;
                    OnPropertyChanged("Loading");
                }
            }
        }

        // INotifyPropertyChanged
        public event PropertyChangedEventHandler PropertyChanged;
        public void OnPropertyChanged(string element)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(element));
        }
    }
}
